﻿using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Diagnostics;

namespace Mrsoft.Controls
{

    public abstract class Ngen
    {
        [System.Security.SecuritySafeCritical]
        public static void NgenFile(string fileName)
        {
            string envDir = RuntimeEnvironment.GetRuntimeDirectory();
            string ngenPath = Path.Combine(envDir, "ngen.exe");
            Console.WriteLine(ngenPath);
            Process ngenProcess = new Process
            {
                StartInfo =
                {
                    FileName = ngenPath,
                    Arguments = "install " + fileName,
                    CreateNoWindow = true,
                    WindowStyle = ProcessWindowStyle.Hidden
                }
            };
            ngenProcess.Start();
            ngenProcess.WaitForExit();
            Console.WriteLine("ok");
        }
    }

}
